Use SFML to load GLSL shaders

OpenGL provides a number of functions for loading, compiling, linking and communicating with shader programmes. But the code involved is not OO, cumbersome and somewhat difficult to work with.

SFML provides a Shader class which acts as object oriented wrapper for OpenGL shaders.

To use ans SFML shader include the header;

 

Create a shader object and load in the vertex and fragments GLSL code. During this process, SFML compile & link the shader programme and will report any compile errors on the console window.

Use the setParameter method to set the value of a shader uniform.

The bind method replaces the FFP with this shader

To switch back on the FFP use;